class Solution {
    public static int countSegments(String s) {
       if(s==null||s.isEmpty()){
           return 0;
       }
       String []S=s.split(" ");
       int count=0;
        for (int i = 0; i < S.length; i++) {
            if(S[i].isEmpty()){
                continue;
            }
            count++;
        }
        return count;
    }

    public static void main(String[] args) {
        String s=" ,, , ,        a, eaefa";
        int ret=countSegments(s);
        System.out.println(ret);
        String a="";
        System.out.println(a.isEmpty());
    }
}